<?php
    require('init.php');
    if(Tools::getValue('envoie')) {
        $employe = Employe::connect(Tools::getValue('email'), Tools::getValue('mdp'));
        if($employe instanceof Employe) {
            $acces = $employe->autorisation(Module::rechercheModule(2));
            if($employe instanceof Employe && $acces instanceof Access && $acces->getDroit() == 1) {
                $_SESSION['employe'] = $employe;
                Tools::redirect('index.php');
            }
            else {
                Tools::redirect('connexion.php?mauvais_couple=1');
            }
        }
        else {
            Tools::redirect('connexion.php?mauvais_couple=1');
        }
    }
    else {
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>GrindHouse Leather</title>
        <script src="js/jquery-2.0.3.min.js"></script>
        <script src="js/script.js"></script>
        <link rel="stylesheet" type="text/css" href="../css/admin.css">
        <link rel="stylesheet" type="text/css" href="../css/960_12_col.css">
    </head>
    <body style="background-color:#AAAAAA">
        <div class="accueil_div_connexion">
            <img src="../img/logo.png" class="accueil_logo" />
            <form method="POST" action="connexion.php">
                <label>
                    Email
                </label>
                <input type="text" name="email" size="50" /><br>
                <label>
                    Mot de passe
                </label>
                <input type="password" name="mdp" size="50" /><br>
                <input type="submit" name="envoie" class="btn" value="Se connecter" />
            </form>
        </div>
    </body>
</html>
<?php
    }
?>

